<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>拍卖列表</title>

    <link href="../../resource/css/bootstrap.min.css?v=3.3.5" rel="stylesheet"
          th:href="@{/resource/css/bootstrap.min.css?v=3.3.5}"/>
    <link href="../../resource/hotui/css/font-awesome.min.css" th:href="@{/resource/hotui/css/font-awesome.min.css}"
          rel="stylesheet">
    <!-- Morris -->
    <link href="../../resource/hotui/css/plugins/morris/morris-0.4.3.min.css"
          th:href="@{/resource/hotui/css/plugins/morris/morris-0.4.3.min.css}" rel="stylesheet">
    <link href="../../resource/css/animate.min.css" rel="stylesheet" th:href="@{/resource/css/animate.min.css}"/>
    <link href="../../resource/hotui/css/style.min-1.0.8.css" th:href="@{/resource/hotui/css/style.min-1.0.8.css}"
          rel="stylesheet">
    <link href="../../resource/hotui/css/hotui.style.override.css"
          th:href="@{/resource/hotui/css/hotui.style.override.css}" rel="stylesheet"/>
    <link href="../../resource/hotui/js/plugins/datetimepick/css/daterangepicker.css"
          th:href="@{/resource/hotui/js/plugins/datetimepick/css/daterangepicker.css}" rel="stylesheet"/>

    <style type="text/css">
        .hr-line-dashed {
            margin: 10px 0;
            height: 1px;
            border-top: 1px dashed #e7eaec;
            background-color: #fff;
            color: #fff;
        }
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight tooltip-demo">
    <!--search-->
    <form role="form" id="searchForm" class="search-panel" method="get"
          th:object="${condition}">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox">
                    <div class="ibox-content">
                        <div class="form-inline">
                            <input type="hidden" th:value="${pageIndex}" name="pageIndex"/>
                            <input type="hidden" th:value="*{auctionStatus}" name="auctionStatus" id="auctionStatus"/>
                            <div class="form-group m-r-sm">
                                <label class=" control-label" for="productName">商品名称：</label>
                                <input type="text" class="form-control input-sm mb10" id="productName"
                                       th:value="*{productName}"
                                       name="productName" placeholder="商品名称" style="width: 156px;"/>
                            </div>
                            <div sec:authorize="hasRole('ADMIN')" class="form-group m-r-sm">
                                <label class=" control-label" for="merchantKey">商家：</label>
                                <input type="text" class="form-control input-sm mb10" id="merchantKey"
                                       th:value="*{merchantKey}"
                                       name="merchantKey" placeholder="商家" style="width: 156px;"/>
                            </div>
                            <div class="form-group m-r-sm">
                                <button type="button" onclick="listHandler.search(1)"
                                        class="btn btn-primary btn-sm m-b-none searchBtn">筛选
                                </button>
                                <button type="button" onclick="listHandler.searchAll()"
                                        class="btn btn-primary btn-sm m-b-none">重置
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
    <!--search-->

    <!--list-->
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins m-b-none">
                <div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li class="active"
                            th:class="${condition.auctionStatus==1?'active':''}">
                            <a th:href="@{/auction/list(auctionStatus=1)}" href="#">进行中</a>
                        </li>
                        <li th:class="${condition.auctionStatus==0?'active':''}">
                            <a th:href="@{/auction/list(auctionStatus=0)}">未开始</a>
                        </li>
                        <li th:class="${condition.auctionStatus==2?'active':''}">
                            <a th:href="@{/auction/list(auctionStatus=2)}">已结束</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active">
                            <div class="panel-body table-responsive">
                                <table class="table table-bordered table-hover table-center">
                                    <thead>
                                    <tr>
                                        <th>商品</th>
                                        <th sec:authorize="hasRole('ADMIN')">商家</th>
                                        <th>当前价</th>
                                        <th>起拍价</th>
                                        <th>加价幅度</th>
                                        <th>保证金</th>
                                        <th>开始时间</th>
                                        <th>结束时间</th>
                                        <th>状态</th>
                                        <th>直播</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>

                                    <tr th:each="item:${list}">
                                        <td>
                                            <p style="width: 100%; height: 50px;">
                                                <!--商品-->
                                                <img th:src="${@resourceService.get(item.productPO.mainPic).getURI()}"
                                                     style="width: 50px; height: 50px; float: left; margin-left: 5px;"
                                                     src=""/>
                                                <span th:text="${item.productPO.productName}"
                                                      style="margin-top: 30px;overflow: hidden; text-align: left; margin-left: 10px; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; width: 54%; float: left;">商品名称</span>
                                            </p>
                                        </td>
                                        <td sec:authorize="hasRole('ADMIN')">
                                            <span th:text="${item.productPO.merchantPO.data.title}"></span>
                                            <br>
                                            <span th:text="${item.productPO.merchantPO.username}"></span>
                                        </td>
                                        <td th:text="${item.currentPrice()}"></td>
                                        <td th:text="${item.startingPrice}"></td>
                                        <td th:text="${item.unitIncrease}"></td>
                                        <td th:text="${item.securityDeposit}"></td>
                                        <td th:text="${#temporals.format(item.startTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                                        <td th:text="${#temporals.format(item.endTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                                        <td th:class="${item.auctionStatus.statusClass()}"
                                            th:text="${item.auctionStatus.desc}"></td>
                                        <td th:text="${item.productPO.roomId>0?'是':'否'}"></td>
                                        <td>
                                            <a th:href="|javascript:listHandler.bidList(${item.id})|"
                                               href="javascript:listHandler.bidList()">出价记录</a>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                                <p style="float: left; margin: 20px 0;">
                                    共<span th:text="${totalRecords}"></span>条记录，当前第<span th:text="${pageIndex}"></span>/<span
                                        th:text="${totalPages==0?1:totalPages}"></span>，每页20条记录
                                </p>
                                <ul style="float: right;" class="pagination pagination-split">
                                </ul>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>

<script type="text/html" id="query_track_modal">
    <div class="ibox float-e-margins" style="width: 520px;max-height: 450px;overflow: auto;">
        <input type="hidden" id="track_bill_id"/>
        <div class="ibox-content timeline">
            <div class="timeline-item" id="track_content">

            </div>
        </div>
    </div>
</script>

<script type="text/html" id="track_content_template">
    <div class="row">
        <div class="col-lg-4" style="margin-top: 10px;">
            {{time}}
        </div>
        <div class="col-lg-8 content no-top-border" style="min-height: 60px;">
            <p class="m-b-xs"><strong>{{context}}</strong>
            </p>
        </div>
    </div>
</script>

<!--基础框架js-->
<script src="../../resource/js/jquery.min.js?v=2.1.4" th:src="@{/resource/js/jquery.min.js?v=2.1.4}"></script>
<script src="../../resource/js/bootstrap.min.js?v=3.3.5" th:src="@{/resource/js/bootstrap.min.js?v=3.3.5}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-utils.js"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-utils.js(123123)}"></script>
<script src="../../resource/hotui/js/hot/bootstrap.hot.extra-init.js"
        th:src="@{/resource/hotui/js/hot/bootstrap.hot.extra-init.js}"></script>
<script src="../../resource/hotui/js/content.min.js" th:src="@{/resource/hotui/js/content.min.js}"></script>
<script src="../../resource/lib/moment.min.js" th:src="@{/resource/lib/moment.min.js}"></script>
<script src="../../resource/hotui/js/plugins/datetimepick/js/daterangepicker.js"
        th:src="@{/resource/hotui/js/plugins/datetimepick/js/daterangepicker.js}"></script>


<script type="text/javascript" th:inline="javascript">
    const pageIndex = /*[[${pageIndex}]]*/  1;
    const totalPages = /*[[${totalPages}]]*/  0;
    const pageUri = /*[[@{/auction/list}]]*/  "";
    const auctionUri = /*[[@{/auction}]]*/  "";
</script>
<script>
    $(function () {
        //初始化分页
        var pageinate = new hot.paging(".pagination", pageIndex, totalPages, 7);

        pageinate.init(function (p) {
            listHandler.search(p);
        });
        $(document).keyup(function (event) {
            if (event.keyCode === 13) {
                $(".searchBtn").trigger("click");
            }
        });
    });

    var listHandler = {
        search: function (pageIndex) {
            $("input[name=pageIndex]").val(pageIndex);
            $("#searchForm").submit();
        },
        searchAll: function () {
            window.location.href = pageUri + "?auctionStatus=" + $("#auctionStatus").val();
        },
        bidList: function (productId) {
            let uri = auctionUri + "/bidList?sessionId=" + productId;
            hot.iframeModal(uri, '400px', '600px', "出价记录");
        }
    }
</script>
</body>
</html>
